Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@types/query-string
Advanced tools
@types/query-string provides TypeScript type definitions for the query-string library, which is used to parse and stringify URL query strings.
Parse a query string
This feature allows you to parse a query string into an object. The example demonstrates parsing a query string with multiple parameters, including repeated keys.
const queryString = require('query-string');
const parsed = queryString.parse('?foo=bar&abc=xyz&abc=123');
console.log(parsed); // { foo: 'bar', abc: ['xyz', '123'] }
Stringify an object into a query string
This feature allows you to convert an object into a query string. The example shows how an object with multiple parameters, including arrays, is stringified.
const queryString = require('query-string');
const stringified = queryString.stringify({ foo: 'bar', abc: ['xyz', '123'] });
console.log(stringified); // 'foo=bar&abc=xyz&abc=123'
Parse a query string with nested objects
This feature allows you to parse query strings that contain nested objects. The example demonstrates parsing a query string with a nested object.
const queryString = require('query-string');
const parsed = queryString.parse('?foo[bar]=baz');
console.log(parsed); // { foo: { bar: 'baz' } }
Stringify an object with nested objects
This feature allows you to convert an object with nested objects into a query string. The example shows how a nested object is stringified.
const queryString = require('query-string');
const stringified = queryString.stringify({ foo: { bar: 'baz' } });
console.log(stringified); // 'foo[bar]=baz'
The 'qs' package is another popular library for parsing and stringifying query strings. It offers more advanced features and customization options compared to query-string, such as handling nested objects and arrays more gracefully.
The 'url-search-params' package is a polyfill for the URLSearchParams interface, which is a native JavaScript API for working with query strings. It provides a more modern and standardized approach compared to query-string.
The 'querystring' module is a core Node.js module for parsing and formatting URL query strings. It is more basic and less feature-rich compared to query-string, but it is built into Node.js and does not require an additional dependency.
npm install --save @types/query-string
This package contains type definitions for query-string (https://github.com/sindresorhus/query-string).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/query-string
Additional Details
These definitions were written by Sam Verschueren https://github.com/SamVerschueren, Tanguy Krotoff https://github.com/tkrotoff, HuHuanming https://github.com/huhuanming, Madara Uchiha https://github.com/MadaraUchiha.
FAQs
Stub TypeScript definitions entry for query-string, which provides its own types definitions
We found that @types/query-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.